package com.navinfo.tripanalysis.offline.service.impl.huashen;


import com.navinfo.tripanalysis.common.pojo.PointProtocol;
import com.navinfo.tripanalysis.common.pojo.RunningType;
import com.navinfo.tripanalysis.common.pojo.RunningTypeEnum;
import com.navinfo.tripanalysis.offline.service.DataCleaningJudgeTripStatusService;

/**
 * 一汽数据清洗：行程切分逻辑
 */
@RunningType(value = RunningTypeEnum.HS, interfaceClass = DataCleaningJudgeTripStatusService.class )
public class DataCleaningJudgeTripStatusServiceImpl implements DataCleaningJudgeTripStatusService {

    /**
     * 精准切分转速阀值
     */
    private final int PRECISE_ROTATION_THRESHOLD = 100;

    @Override
    public int judgeTripStatus(Long lastGpsTime, Long gpsTime, PointProtocol point) {
        //行程未开始
        if (lastGpsTime == null) {
            return point.getRotation()>PRECISE_ROTATION_THRESHOLD ? TRIP_START : TRIP_NO_START;
        }
        //行程已开始
        else {
            if (isForceEnd(lastGpsTime, gpsTime)) {
                return TRIP_FORCE_END;
            } else {
                return point.getRotation()>PRECISE_ROTATION_THRESHOLD ? TRIP_IN : TRIP_END;
            }
        }
    }
}
